#pragma once
#include <iostream>
#include <unistd.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

using namespace std;

/*
 *  std::string *: 输出型参数
 *  const std::string &: 输入型参数
 *  std::string &: 输入输出型参数
*/

const string gpipefile = "./fifo";
const mode_t gmode = 0600;
const int gdefaultfd = -1;
const int gsize = 1024;
const int gForRead = O_RDONLY;
const int gForWrite = O_WRONLY;

int OpenPipe(const int &flag)
{
    int fd = ::open(gpipefile.c_str(), flag);
    if (fd < 0)
    {
        cerr << "open pipe error" << endl;
    }
    return fd;
}

void ClosePipeHelper(const int &fd)
{
    if(fd >= 0)
    {
        ::close(fd);
    }
}